﻿using DevExpress.XtraBars;
using DevExpress.XtraGrid.Views.Base;
using NAGFwk.BL;
using NAGFwk.UI;
using SilkeyERP.BL;

namespace SilkeyERP.UI.Entities.Currency
{
    public partial class ContentView : BaseContentDetail
    {
        private IBaseController<Model.Currency> _controller = new CurrencyController();
        public override string ModuleName { get { return "Currency"; } }

        public ContentView()
        {
            InitializeComponent();
        }

        public override void ShowModule(bool firstShow)
        {            
            MapItLoad(_controller);        
        }

        private void bbiDelete_ItemClick(object sender, ItemClickEventArgs e)
        {
            MapItDelete(_controller);
        }

        private void bbiRefresh_ItemClick(object sender, ItemClickEventArgs e)
        {
            RefreshAll();
        }
        protected override void ValidateRows(ValidateRowEventArgs e)
        {
            var typedRow = ((Model.Currency)e.Row);
            if(string.IsNullOrEmpty(typedRow.Symbol))
            {
                e.ErrorText = "Simbolo es Requerido.";
                e.Valid = false;
                }
        }      
        private void RefreshAll()
        {
            _controller = MapItRefresh(new CurrencyController());
        }
    }
}
